package designpatterns.obsever.code;

import jdk.jdk8.localdate.LocalDateTimeUtils;

import java.time.LocalDateTime;

public class TenantsWeather implements Observer{
    public TenantsWeather() {
        name = "腾讯天气";
    }

    @Override
    public void update(WeatherChangeEvent event) {
        this.temperature = event.getTemperature();
        this.humidity = event.getHumidity();
        display();
    }

    public void display() {
        String now = LocalDateTimeUtils.format(LocalDateTime.now(), LocalDateTimeUtils.DEFAULT_DATE_PATTERN);
        System.out.println("=============="+now+"【"+ this.name + "】播报天气============");
        System.out.println("____【气温】:"+temperature);
        System.out.println("____【湿度】:"+humidity);
    }

    private String name;
    // 温度
    private Float temperature;
    // 湿度
    private Float humidity;
}
